<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">home</el-breadcrumb-item>
      <el-breadcrumb-item>insurancelist</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card>
      <!-- 险种分类列表区域 -->
      <el-table :data="list" border stripe>
        <el-table-column label="insuranceID" prop="_id"></el-table-column>
        <el-table-column label="insurancename" prop="name"></el-table-column>
        <el-table-column label="operate">
          <template slot-scope="scope">
            <el-button size="mini" @click="$router.push('/modiinsurancer/'+scope.row._id)">modification</el-button>
            <el-button size="mini" type="danger" @click="deletes(scope.row._id)">delete</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions } = createNamespacedHelpers("insurancetype");
export default {
  data() {
    return {
      list: [],
    };
  },
  async created() {
    const data = await this.lgetAllInsurances();
    this.list = data.data;
  },
  methods: {
    ...mapActions(["lgetAllInsurances"]),
    ...mapActions(["deleteInsurances"]),
    deletes(_id) {
      // this.deleteInsurances(_id);
      this.$confirm("此操作将永久删除该学生信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.deleteInsurances(_id);
         const data =  await this.lgetAllInsurances();
          this.list = data.data;
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style>
</style>